<?php

namespace App\Http\Form\KfCashRegisterV2;


use App\Enums\WorkOrder\OrderEnum;
use App\Http\Form\Form;
use App\Http\Form\FormAttribute;
use App\Http\Form\FormInterface;
use App\Http\Form\FormValidate;
use App\Models\WorkOrder\WorkOrderApplyContentModel;
use App\Models\WorkOrder\WorkOrderApplyMainModel;
use App\Support\CustomForm\Attribute\AttributeMapSupport;
use App\Support\CustomForm\Attribute\AttributeSupport;
use App\Support\CustomForm\AttributeWorkOrderSupport;
use App\Support\CustomForm\Validate\ValidateSupport;
use App\Support\Facade\CustomerValidator;
use Illuminate\Support\Collection;
use Illuminate\Validation\Validator;

/**
 *
 * @property KfCashRegisterV2FormAttribute businessType
 * @property KfCashRegisterV2FormAttribute settlementType
 * @property KfCashRegisterV2FormAttribute authorizationLetterImg
 *
 * @property KfCashRegisterV2FormAttribute businessLicenseImg
 * @property KfCashRegisterV2FormAttribute businessCompanyArea
 * @property KfCashRegisterV2FormAttribute enterpriseName
 * @property KfCashRegisterV2FormAttribute businessLicenseNumber
 * @property KfCashRegisterV2FormAttribute businessLicenseRegistrationDate
 * @property KfCashRegisterV2FormAttribute businessLicenseValidityPeriodType
 * @property KfCashRegisterV2FormAttribute businessLicenseEndDate
 * @property KfCashRegisterV2FormAttribute businessPremises
 * @property KfCashRegisterV2FormAttribute businessUserName
 *
 * @property KfCashRegisterV2FormAttribute legalPersonIdentityCardFront
 * @property KfCashRegisterV2FormAttribute legalPersonIdentityCardBack
 * @property KfCashRegisterV2FormAttribute legalPersonUsername
 * @property KfCashRegisterV2FormAttribute legalPersonIdentityCardNumber
 * @property KfCashRegisterV2FormAttribute legalPersonIdentityCardValidityPeriod
 * @property KfCashRegisterV2FormAttribute legalPersonMobile
 *
 *
 *
 * @property KfCashRegisterV2FormAttribute companyBankCardImg
 * @property KfCashRegisterV2FormAttribute companyBankCardNumber
 * @property KfCashRegisterV2FormAttribute companyBankCardBank
 * @property KfCashRegisterV2FormAttribute companyBankCardBankArea
 * @property KfCashRegisterV2FormAttribute companyBankCardBranchBank
 * @property KfCashRegisterV2FormAttribute companyBankCardReserveMobile
 *
 * @property KfCashRegisterV2FormAttribute payeeType
 * @property KfCashRegisterV2FormAttribute merchantRelationshipImg
 * @property KfCashRegisterV2FormAttribute payeeIdentityCardFront
 * @property KfCashRegisterV2FormAttribute payeeIdentityCardBack
 * @property KfCashRegisterV2FormAttribute payeeUsername
 * @property KfCashRegisterV2FormAttribute payeeIdentityCardNumber
 * @property KfCashRegisterV2FormAttribute payeeIdentityCardValidityPeriod
 * @property KfCashRegisterV2FormAttribute payeeMobile
 *
 * @property KfCashRegisterV2FormAttribute legalPersonBankCardFrontImg
 * @property KfCashRegisterV2FormAttribute legalPersonBankCardNumber
 * @property KfCashRegisterV2FormAttribute legalPersonBankCardBank
 * @property KfCashRegisterV2FormAttribute legalPersonBankCardBankArea
 * @property KfCashRegisterV2FormAttribute legalPersonBankCardBranchBank
 * @property KfCashRegisterV2FormAttribute legalPersonBankCardReserveMobile
 *
 */
class KfCashRegisterV2Form extends Form implements FormInterface
{


    public function businessInfo(Collection $formContent)
    {
//      * @property KfCashRegisterV2FormAttribute businessType
//      * @property KfCashRegisterV2FormAttribute settlementType
//      * @property KfCashRegisterV2FormAttribute authorizationLetterImg
        KfCashRegisterV2FormAttribute::getInstance(
            "businessType",
            AttributeSupport::INPUT_TYPE_SELECT,
            "商户类型"
        )->setValidateRules(
            KfCashRegisterV2FormValidate::getInstance()->setRequired(true)
                                        ->setDataType(ValidateSupport::DATA_TYPE_INT)
                                        ->setIn(array_keys(KfCashRegisterV2FormAttribute::BUSINESS_TYPE_MAP))
        )->setOptions(
            KfCashRegisterV2FormAttribute::BUSINESS_TYPE_MAP
        )->setValue($formContent, "");

        KfCashRegisterV2FormAttribute::getInstance(
            "settlementType",
            AttributeSupport::INPUT_TYPE_SELECT,
            "结算方式"
        )->setValidateRules(
            KfCashRegisterV2FormValidate::getInstance()->setRequired(true)
                ->setDataType(ValidateSupport::DATA_TYPE_INT)
                ->setIn(array_keys(KfCashRegisterV2FormAttribute::SETTLEMENT_TYPE_MAP))
        )->setOptions(
            KfCashRegisterV2FormAttribute::SETTLEMENT_TYPE_MAP
        )->setValue($formContent, '');

        KfCashRegisterV2FormAttribute::getInstance(
            "authorizationLetterImg",
            AttributeSupport::INPUT_TYPE_IMG_GROUP,
            "夸父品牌授权书",
            true
        )->setCustomAttribute(
            ["download", true],
            ["check", true]
        )->setValidateRules(
            KfCashRegisterV2FormValidate::getInstance()->setRequired(false)
                                        ->setDataType(ValidateSupport::DATA_TYPE_ARRAY)
                                        ->setContentLength(1, 1)
        )->registerHandleSaveValueFunc(
            FormAttribute::getImgGroupSaveFunc()
        )->setExampleImages(
            ["https://file.51kuafu.com/1a/c3/330483dee327bc7410a36906b6fe7d88be2a76458646fbb060b8dde5cb40.png"]
        )->setRemark(
            '授权书下载地址：夸父商家-我的-开店订单-合同资料-运营资料-开店授权书'
        )->setValue(
            $formContent, ""
        )->setBeforeBuildHandle(function (AttributeSupport $attributeSupport) use ($formContent) {
            if ($formContent->get("initAuthorizationLetterImg", false)) {
                $attributeSupport->setCustomAttribute(["disabled", true]);
            }
        });
    }

    /**
     * 执照信息
     *
     * @param Collection $formContent
     */
    public function licenseInformation(Collection $formContent)
    {
        //        * @property KfCashRegisterV2FormAttribute businessLicenseImg
        //        * @property KfCashRegisterV2FormAttribute enterpriseName
        //        * @property KfCashRegisterV2FormAttribute businessLicenseNumber
        //        * @property KfCashRegisterV2FormAttribute businessLicenseRegistrationDate
        //        * @property KfCashRegisterV2FormAttribute businessLicenseValidityPeriodType
        //        * @property KfCashRegisterV2FormAttribute businessLicenseEndDate
        //        * @property KfCashRegisterV2FormAttribute businessPremises
        //对私选填
        KfCashRegisterV2FormAttribute::getInstance(
            'businessLicenseImg',
            AttributeSupport::INPUT_TYPE_IMG_GROUP,
            '营业执照照片',
            true
        )->registerHandleSaveValueFunc(
            KfCashRegisterV2FormAttribute::getImgGroupSaveFunc()
        )->setCustomAttribute(
            ['download', true],
            ['check', true]
        )->setValidateRules(
            KfCashRegisterV2FormValidate::imgGroupValidate()
        )->setExampleImages(
            ['https://file.51kuafu.com/03/6c/7afb9bc267275a8448c285587d8cba592c793150406e75e1c2b9cda59690.png']
        )->setValue(
            $formContent, []
        );

        KfCashRegisterV2FormAttribute::getInstance(
            'businessCompanyArea',
            AttributeSupport::INPUT_TYPE_FY_ADDRESS,
            '营业执照所在省市区'
        )->setValidateRules(
            KfCashRegisterV2FormValidate::fyAddressValidate()
        )->setPlaceholder(
            '请填写营业执照所在省市区'
        )->setValue($formContent, []);

        KfCashRegisterV2FormAttribute::getInstance(
            'enterpriseName',
            AttributeSupport::INPUT_TYPE_STRING,
            '企业名称'
        )->setValidateRules(
            KfCashRegisterV2FormValidate::stringValidate(0, 72, false)
        )->setPlaceholder(
            '请填写企业名称'
        )->setValue(
            $formContent, ''
        );

        KfCashRegisterV2FormAttribute::getInstance(
            'businessLicenseNumber',
            AttributeSupport::INPUT_TYPE_STRING,
            '统一信用代码'
        )->setValidateRules(
            KfCashRegisterV2FormValidate::stringValidate(0, 36, false)
        )->setPlaceholder(
            '请输入'
        )->setValue(
            $formContent, ''
        );

        KfCashRegisterV2FormAttribute::getInstance(
            'businessLicenseRegistrationDate',
            AttributeSupport::INPUT_NEW_DATE,
            '注册日期'
        )->setValidateRules(
            KfCashRegisterV2FormValidate::dateValidate('Y-m-d')
        )->setDateFormat(
            AttributeSupport::DATE_FORMAT_1
        )->setPlaceholder(
            '请选择注册日期'
        )->setValue($formContent, '');

        KfCashRegisterV2FormAttribute::getInstance(
            'businessLicenseValidityPeriodType',
            AttributeSupport::INPUT_TYPE_SELECT,
            '证件期限'
        )->setValidateRules(
            KfCashRegisterV2FormValidate::getInstance()->setRequired(true)
                ->setDataType(ValidateSupport::DATA_TYPE_INT)
                ->setIn(array_keys(KfCashRegisterV2FormAttribute::BUSINESS_LICENSE_TYPE_MAP))
        )->setOptions(
            KfCashRegisterV2FormAttribute::BUSINESS_LICENSE_TYPE_MAP
        )->setValue($formContent, '');


        KfCashRegisterV2FormAttribute::getInstance(
            'businessLicenseEndDate',
            AttributeSupport::INPUT_NEW_DATE,
            '有效期'
        )->setValidateRules(
            KfCashRegisterV2FormValidate::dateValidate('Y-m-d')
                ->setExcludeEq([[$this->businessLicenseValidityPeriodType->getInputName() => KfCashRegisterV2FormAttribute::BUSINESS_LICENSE_TYPE]])
        )->setDateFormat(
            AttributeSupport::DATE_FORMAT_1
        )->setPlaceholder(
            '请选择有效期'
        )->setValue(
            $formContent, ''
        )->setAllRelations(
            [$this->businessLicenseValidityPeriodType->getInputName() => KfCashRegisterV2FormAttribute::BUSINESS_LICENSE_TYPE]
        );

        /*KfCashRegisterV2FormAttribute::getInstance(
            "businessLicenseValidityPeriod",
            AttributeSupport::INPUT_DATE_RANGE,
            "有效期"
        )->setValidateRules(
            KfCashRegisterV2FormValidate::dateRangeValidate("Y-m-d")
        )->setDateFormat(
            AttributeSupport::DATE_FORMAT_1
        )->setCustomAttribute(
            ["disabled", false]
        )->setValue($formContent, "");*/

        KfCashRegisterV2FormAttribute::getInstance(
            'businessPremises',
            AttributeSupport::INPUT_TYPE_TEXT,
            '经营地址'
        )->setValidateRules(
            KfCashRegisterV2FormValidate::getInstance()->setRequired(true)
                ->setDataType(ValidateSupport::DATA_TYPE_STRING)
                ->setContentLength(0, 120)
        )->setPlaceholder(
            '请填写证件上所示的经营地址'
        )->setValue($formContent, '');

        KfCashRegisterV2FormAttribute::getInstance(
            'businessUserName',
            AttributeSupport::INPUT_TYPE_STRING,
            '执照法人'
        )->setValidateRules(
            KfCashRegisterV2FormValidate::stringValidate(0, 12, true)
        )->setPlaceholder(
            '请填写证件上所示的执照法人'
        )->setValue($formContent, '');


    }

    /**
     * 法人信息
     *
     * @param Collection $formContent
     */
    public function legalPersonInfo(Collection $formContent)
    {
//        * @property KfCashRegisterV2FormAttribute legalPersonIdentityCardFront
//        * @property KfCashRegisterV2FormAttribute legalPersonIdentityCardBack
//        * @property KfCashRegisterV2FormAttribute legalPersonUsername
//        * @property KfCashRegisterV2FormAttribute legalPersonIdentityCardNumber
//        * @property KfCashRegisterV2FormAttribute legalPersonIdentityCardValidityPeriod
//        * @property KfCashRegisterV2FormAttribute legalPersonMobile

        KfCashRegisterV2FormAttribute::getInstance(
            "legalPersonIdentityCardFront",
            AttributeSupport::INPUT_TYPE_IMG_GROUP,
            "身份证人像面",
            true
        )->setCustomAttribute(
            ["download", true],
            ["check", true]
        )->registerHandleSaveValueFunc(
            KfCashRegisterV2FormAttribute::getImgGroupSaveFunc()
        )->setCustomAttribute(
            ["descList", WorkOrderApplyContentModel::DEFAULT_PERSON_IDENTITY_CARD_DESC_LIST]
        )->setValidateRules(
            KfCashRegisterV2FormValidate::imgGroupValidate()
        )->setExampleImages(
            ["https://file.51kuafu.com/64/a4/613f464330f89f1fe43b35ba667b023178af84b4c7ef4574ed0e01c867a5.png"]
        )->setValue($formContent, "");

        KfCashRegisterV2FormAttribute::getInstance(
            "legalPersonIdentityCardBack",
            AttributeSupport::INPUT_TYPE_IMG_GROUP,
            "身份证国徽面",
            true
        )->registerHandleSaveValueFunc(
            KfCashRegisterV2FormAttribute::getImgGroupSaveFunc()
        )->setCustomAttribute(
            ["download", true],
            ["check", true]
        )->setCustomAttribute(
            ["descList", WorkOrderApplyContentModel::DEFAULT_PERSON_IDENTITY_CARD_DESC_LIST]
        )->setValidateRules(
            KfCashRegisterV2FormValidate::imgGroupValidate()
        )->setExampleImages(
            ["https://file.51kuafu.com/49/49/784be96a9a10a712d946f3f184b263e074aeb9cea3ed6c7b125f4ed2dd9b.png"]
        )->setValue($formContent, "");

        KfCashRegisterV2FormAttribute::getInstance(
            "legalPersonUsername",
            AttributeSupport::INPUT_TYPE_STRING,
            "法人姓名"
        )->setValidateRules(
            KfCashRegisterV2FormValidate::stringValidate(0, 12, true)
        )->setCustomAttribute(
            ['disabled', true]
        )->setPlaceholder(
            "请填写法人姓名"
        )->setValue($formContent, "");

        KfCashRegisterV2FormAttribute::getInstance(
            "legalPersonIdentityCardNumber",
            AttributeSupport::INPUT_TYPE_STRING,
            "证件号码"
        )->setValidateRules(
            KfCashRegisterV2FormValidate::identityCardValidate()
        )->setCustomAttribute(
            ['disabled', true]
        )->setPlaceholder(
            "请填写法人身份证号"
        )->setValue($formContent, "");


        KfCashRegisterV2FormAttribute::getInstance(
            "legalPersonIdentityCardValidityPeriod",
            AttributeSupport::INPUT_TYPE_STRING,
            "证件有效期"
        )->setValidateRules(
            KfCashRegisterV2FormValidate::stringValidate(0, 36, false)
        )->setValue($formContent, "");

        KfCashRegisterV2FormAttribute::getInstance(
            "legalPersonMobile",
            AttributeSupport::INPUT_TYPE_MOBILE,
            "法人电话"
        )->setValidateRules(
            KfCashRegisterV2FormValidate::mobileValidate()
        )->setPlaceholder(
            "请填写法人电话"
        )->setValue($formContent, "");
    }

    /**
     * 收款信息
     */
    public function collectionInformationForm(Collection $formContent)
    {

//        * @property KfCashRegisterV2FormAttribute companyBankCardImg
//        * @property KfCashRegisterV2FormAttribute companyBankCardNumber
//        * @property KfCashRegisterV2FormAttribute companyBankCardBank
//        * @property KfCashRegisterV2FormAttribute companyBankCardBankArea
//        * @property KfCashRegisterV2FormAttribute companyBankCardBranchBank
//        * @property KfCashRegisterV2FormAttribute companyBankCardReserveMobile


        KfCashRegisterV2FormAttribute::getInstance(
            "companyBankCardImg",
            AttributeSupport::INPUT_TYPE_IMG_GROUP,
            "公户网银截图/公户转账（转出）回单",
            true
        )->registerHandleSaveValueFunc(
            KfCashRegisterV2FormAttribute::getImgGroupSaveFunc()
        )->setCustomAttribute(
            ["download", true],
            ["check", true],
            ['position', 1]
        )->setValidateRules(
            KfCashRegisterV2FormValidate::imgGroupValidate()
                                        ->setExcludeEq(
                                            [
                                                [
                                                    $this->settlementType->getInputName() => KfCashRegisterV2FormAttribute::SETTLEMENT_TYPE_PRIVATE,
                                                    $this->businessType->getInputName()   => KfCashRegisterV2FormAttribute::BUSINESS_TYPE_BUSINESS
                                                ],
                                                [$this->settlementType->getInputName() => KfCashRegisterV2FormAttribute::SETTLEMENT_TYPE_PUBLIC]
                                            ]
                                        )
        )->setAllRelations(
            [
                $this->settlementType->getInputName() => KfCashRegisterV2FormAttribute::SETTLEMENT_TYPE_PRIVATE,
                $this->businessType->getInputName()   => KfCashRegisterV2FormAttribute::BUSINESS_TYPE_BUSINESS
            ]
        )->setAllRelations(
            [$this->settlementType->getInputName() => KfCashRegisterV2FormAttribute::SETTLEMENT_TYPE_PUBLIC]
        )->setExampleImages(
            ["https://img.51kuafu.com/1/0/6c2c3c82965fed85aef3e6abd831995d.jpeg"]
        )->setValue($formContent, "");

        KfCashRegisterV2FormAttribute::getInstance(
            "companyBankCardNumber",
            AttributeSupport::INPUT_TYPE_STRING,
            "公户账号"
        )->setCustomAttribute(
            ['position', 1]
        )->setValidateRules(
            KfCashRegisterV2FormValidate::stringValidate(9, 20)->setExcludeEq(
                [
                    [
                        $this->settlementType->getInputName() => KfCashRegisterV2FormAttribute::SETTLEMENT_TYPE_PRIVATE,
                        $this->businessType->getInputName()   => KfCashRegisterV2FormAttribute::BUSINESS_TYPE_BUSINESS
                    ],
                    [$this->settlementType->getInputName() => KfCashRegisterV2FormAttribute::SETTLEMENT_TYPE_PUBLIC]
                ]
            )
        )->setAllRelations(
            [
                $this->settlementType->getInputName() => KfCashRegisterV2FormAttribute::SETTLEMENT_TYPE_PRIVATE,
                $this->businessType->getInputName()   => KfCashRegisterV2FormAttribute::BUSINESS_TYPE_BUSINESS
            ]
        )->setAllRelations(
            [$this->settlementType->getInputName() => KfCashRegisterV2FormAttribute::SETTLEMENT_TYPE_PUBLIC]
        )->setPlaceholder(
            "请填写公户开户银行卡号"
        )->setValue($formContent, "");

        KfCashRegisterV2FormAttribute::getInstance(
            "companyBankCardBank",
            AttributeSupport::INPUT_TYPE_SELECT,
            "公户开户银行"
        )->setCustomAttribute(
            ['position', 1]
        )->setValidateRules(
            KfCashRegisterV2FormValidate::stringValidate(1, 12)->setExcludeEq(
                [
                    [
                        $this->settlementType->getInputName() => KfCashRegisterV2FormAttribute::SETTLEMENT_TYPE_PRIVATE,
                        $this->businessType->getInputName()   => KfCashRegisterV2FormAttribute::BUSINESS_TYPE_BUSINESS
                    ],
                    [$this->settlementType->getInputName() => KfCashRegisterV2FormAttribute::SETTLEMENT_TYPE_PUBLIC]
                ]
            )
        )->setAllRelations(
            [
                $this->settlementType->getInputName() => KfCashRegisterV2FormAttribute::SETTLEMENT_TYPE_PRIVATE,
                $this->businessType->getInputName()   => KfCashRegisterV2FormAttribute::BUSINESS_TYPE_BUSINESS
            ]
        )->setAllRelations(
            [$this->settlementType->getInputName() => KfCashRegisterV2FormAttribute::SETTLEMENT_TYPE_PUBLIC]
        )->setOptions(
            KfCashRegisterV2FormAttribute::FY_BANK_TYPE
        )->setPlaceholder(
            "请填写公户开户银行"
        )->setValue($formContent, "");

        KfCashRegisterV2FormAttribute::getInstance(
            "companyBankCardBankArea",
            AttributeSupport::INPUT_TYPE_FY_ADDRESS,
            "公户银行所在省市区"
        )->setCustomAttribute(
            ['position', 1]
        )->setValidateRules(
            KfCashRegisterV2FormValidate::fyAddressValidate()->setExcludeEq(
                [
                    [
                        $this->settlementType->getInputName() => KfCashRegisterV2FormAttribute::SETTLEMENT_TYPE_PRIVATE,
                        $this->businessType->getInputName()   => KfCashRegisterV2FormAttribute::BUSINESS_TYPE_BUSINESS
                    ],
                    [$this->settlementType->getInputName() => KfCashRegisterV2FormAttribute::SETTLEMENT_TYPE_PUBLIC]
                ]
            )
        )->setAllRelations(
            [
                $this->settlementType->getInputName() => KfCashRegisterV2FormAttribute::SETTLEMENT_TYPE_PRIVATE,
                $this->businessType->getInputName()   => KfCashRegisterV2FormAttribute::BUSINESS_TYPE_BUSINESS
            ]
        )->setAllRelations(
            [$this->settlementType->getInputName() => KfCashRegisterV2FormAttribute::SETTLEMENT_TYPE_PUBLIC]
        )->setPlaceholder(
            "请填写公户开户行所在省市区"
        )->setValue($formContent, []);

        KfCashRegisterV2FormAttribute::getInstance(
            "companyBankCardBranchBank",
            AttributeSupport::INPUT_TYPE_SELECT,
            "公户开户支行"
        )->setCustomAttribute(
            ['position', 1]
        )->setValidateRules(
            KfCashRegisterV2FormValidate::stringValidate(1, 36)->setExcludeEq(
                [
                    [
                        $this->settlementType->getInputName() => KfCashRegisterV2FormAttribute::SETTLEMENT_TYPE_PRIVATE,
                        $this->businessType->getInputName()   => KfCashRegisterV2FormAttribute::BUSINESS_TYPE_BUSINESS
                    ],
                    [$this->settlementType->getInputName() => KfCashRegisterV2FormAttribute::SETTLEMENT_TYPE_PUBLIC]
                ]
            )
        )->setAllRelations(
            [
                $this->settlementType->getInputName() => KfCashRegisterV2FormAttribute::SETTLEMENT_TYPE_PRIVATE,
                $this->businessType->getInputName()   => KfCashRegisterV2FormAttribute::BUSINESS_TYPE_BUSINESS
            ]
        )->setAllRelations(
            [$this->settlementType->getInputName() => KfCashRegisterV2FormAttribute::SETTLEMENT_TYPE_PUBLIC]
        )->setOptions(
            []
        )->setPlaceholder(
            "请填写公户开户行所在开户支行"
        )->setValue($formContent, "");


        KfCashRegisterV2FormAttribute::getInstance(
            "companyBankCardReserveMobile",
            AttributeSupport::INPUT_TYPE_MOBILE,
            "公户预留手机号"
        )->setCustomAttribute(
            ['position', 1]
        )->setValidateRules(
            KfCashRegisterV2FormValidate::mobileValidate()->setExcludeEq(
                [
                    [
                        $this->settlementType->getInputName() => KfCashRegisterV2FormAttribute::SETTLEMENT_TYPE_PRIVATE,
                        $this->businessType->getInputName()   => KfCashRegisterV2FormAttribute::BUSINESS_TYPE_BUSINESS
                    ],
                    [$this->settlementType->getInputName() => KfCashRegisterV2FormAttribute::SETTLEMENT_TYPE_PUBLIC]
                ]
            )
        )->setAllRelations(
            [
                $this->settlementType->getInputName() => KfCashRegisterV2FormAttribute::SETTLEMENT_TYPE_PRIVATE,
                $this->businessType->getInputName()   => KfCashRegisterV2FormAttribute::BUSINESS_TYPE_BUSINESS
            ]
        )->setAllRelations(
            [$this->settlementType->getInputName() => KfCashRegisterV2FormAttribute::SETTLEMENT_TYPE_PUBLIC]
        )->setPlaceholder(
            "请填写公户预留手机号"
        )->setValue($formContent, "");

//        -----
//
//        * @property KfCashRegisterV2FormAttribute legalPersonBankCardFrontImg
//        * @property KfCashRegisterV2FormAttribute legalPersonBankCardNumber
//        * @property KfCashRegisterV2FormAttribute legalPersonBankCardBank
//        * @property KfCashRegisterV2FormAttribute legalPersonBankCardBankArea
//        * @property KfCashRegisterV2FormAttribute legalPersonBankCardBranchBank
//        * @property KfCashRegisterV2FormAttribute legalPersonBankCardReserveMobile


        // 非法人收款
        KfCashRegisterV2FormAttribute::getInstance(
            'payeeType',
            AttributeSupport::INPUT_TYPE_SELECT,
            '收款人类型'
        )->setCustomAttribute(
            ['position', 2]
        )->setValidateRules(
            KfCashRegisterV2FormValidate::inIntValidate(KfCashRegisterV2FormAttribute::PAYEE_TYPE_CORPORATION_MAP,true)->setExcludeEq(
                [
                    [$this->settlementType->getInputName() => KfCashRegisterV2FormAttribute::SETTLEMENT_TYPE_PRIVATE]
                ]
            )
        )->setOptions(
            KfCashRegisterV2FormAttribute::PAYEE_TYPE_CORPORATION_MAP
        )->setValue(
            $formContent, ''
        )->setAllRelations(
            [$this->settlementType->getInputName() => KfCashRegisterV2FormAttribute::SETTLEMENT_TYPE_PRIVATE]
        );

        KfCashRegisterV2FormAttribute::getInstance(
            'merchantRelationshipImg',
            AttributeSupport::INPUT_TYPE_IMG_GROUP,
            '商户关系证明',
            true
        )->registerHandleSaveValueFunc(
            KfCashRegisterV2FormAttribute::getImgGroupSaveFunc()
        )->setCustomAttribute(
            ['download', true],
            ['check', true],
            ['position', 2],
            ['buttonText','上传']
        )->setValidateRules(
            KfCashRegisterV2FormValidate::imgGroupValidate()->setExcludeEq(
                [
                    [
                        $this->settlementType->getInputName() => KfCashRegisterV2FormAttribute::SETTLEMENT_TYPE_PRIVATE,
                        $this->payeeType->getInputName()      => KfCashRegisterV2FormAttribute::PAYEE_TYPE_UN_CORPORATION
                    ]
                ]
            )
        )->setExampleFiles(
            FormAttribute::getWaimaiFormConfig('merchantRelationshipConfig')
        )->setAllRelations(
            [
                $this->settlementType->getInputName() => KfCashRegisterV2FormAttribute::SETTLEMENT_TYPE_PRIVATE,
                $this->payeeType->getInputName()      => KfCashRegisterV2FormAttribute::PAYEE_TYPE_UN_CORPORATION
            ]
        )->setValue($formContent, '');

        KfCashRegisterV2FormAttribute::getInstance(
            'payeeIdentityCardFront',
            AttributeSupport::INPUT_TYPE_IMG_GROUP,
            '收款人身份证人像面',
            true
        )->setCustomAttribute(
            ['download', true],
            ['check', true],
            ['position', 2],
            ['descList', WorkOrderApplyContentModel::DEFAULT_PERSON_IDENTITY_CARD_DESC_LIST]
        )->registerHandleSaveValueFunc(
            KfCashRegisterV2FormAttribute::getImgGroupSaveFunc()
        )->setValidateRules(
            KfCashRegisterV2FormValidate::imgGroupValidate()->setExcludeEq(
                [
                    [
                        $this->settlementType->getInputName() => KfCashRegisterV2FormAttribute::SETTLEMENT_TYPE_PRIVATE,
                        $this->payeeType->getInputName()      => KfCashRegisterV2FormAttribute::PAYEE_TYPE_UN_CORPORATION
                    ]
                ]
            )
        )->setExampleImages(
            ['https://file.51kuafu.com/64/a4/613f464330f89f1fe43b35ba667b023178af84b4c7ef4574ed0e01c867a5.png']
        )->setAllRelations(
            [
                $this->settlementType->getInputName() => KfCashRegisterV2FormAttribute::SETTLEMENT_TYPE_PRIVATE,
                $this->payeeType->getInputName()      => KfCashRegisterV2FormAttribute::PAYEE_TYPE_UN_CORPORATION
            ]
        )->setValue($formContent, '');

        KfCashRegisterV2FormAttribute::getInstance(
            'payeeIdentityCardBack',
            AttributeSupport::INPUT_TYPE_IMG_GROUP,
            '收款人身份证国徽面',
            true
        )->registerHandleSaveValueFunc(
            KfCashRegisterV2FormAttribute::getImgGroupSaveFunc()
        )->setCustomAttribute(
            ['download', true],
            ['check', true],
            ['position', 2],
            ['descList', WorkOrderApplyContentModel::DEFAULT_PERSON_IDENTITY_CARD_DESC_LIST]
        )->setValidateRules(
            KfCashRegisterV2FormValidate::imgGroupValidate()->setExcludeEq(
                [
                    [
                        $this->settlementType->getInputName() => KfCashRegisterV2FormAttribute::SETTLEMENT_TYPE_PRIVATE,
                        $this->payeeType->getInputName()      => KfCashRegisterV2FormAttribute::PAYEE_TYPE_UN_CORPORATION
                    ]
                ]
            )
        )->setExampleImages(
            ['https://file.51kuafu.com/49/49/784be96a9a10a712d946f3f184b263e074aeb9cea3ed6c7b125f4ed2dd9b.png']
        )->setAllRelations(
            [
                $this->settlementType->getInputName() => KfCashRegisterV2FormAttribute::SETTLEMENT_TYPE_PRIVATE,
                $this->payeeType->getInputName()      => KfCashRegisterV2FormAttribute::PAYEE_TYPE_UN_CORPORATION
            ]
        )->setValue($formContent, '');

        KfCashRegisterV2FormAttribute::getInstance(
            'payeeUsername',
            AttributeSupport::INPUT_TYPE_STRING,
            '收款人'
        )->setCustomAttribute(
            ['position', 2],
            ['disabled', true]
        )->setValidateRules(
            KfCashRegisterV2FormValidate::stringValidate(0, 12, true)->setExcludeEq(
                [
                    [
                        $this->settlementType->getInputName() => KfCashRegisterV2FormAttribute::SETTLEMENT_TYPE_PRIVATE,
                        $this->payeeType->getInputName()      => KfCashRegisterV2FormAttribute::PAYEE_TYPE_UN_CORPORATION
                    ]
                ]
            )
        )->setPlaceholder(
            '请填写收款人姓名'
        )->setAllRelations(
            [
                $this->settlementType->getInputName() => KfCashRegisterV2FormAttribute::SETTLEMENT_TYPE_PRIVATE,
                $this->payeeType->getInputName()      => KfCashRegisterV2FormAttribute::PAYEE_TYPE_UN_CORPORATION
            ]
        )->setValue($formContent, '');

        KfCashRegisterV2FormAttribute::getInstance(
            'payeeIdentityCardNumber',
            AttributeSupport::INPUT_TYPE_STRING,
            '收款人证件号码'
        )->setCustomAttribute(
            ['position', 2],
            ['disabled', true]
        )->setValidateRules(
            KfCashRegisterV2FormValidate::identityCardValidate()->setExcludeEq(
                [
                    [
                        $this->settlementType->getInputName() => KfCashRegisterV2FormAttribute::SETTLEMENT_TYPE_PRIVATE,
                        $this->payeeType->getInputName()      => KfCashRegisterV2FormAttribute::PAYEE_TYPE_UN_CORPORATION
                    ]
                ]
            )
        )->setPlaceholder(
            '请填写收款人身份证号'
        )->setAllRelations(
            [
                $this->settlementType->getInputName() => KfCashRegisterV2FormAttribute::SETTLEMENT_TYPE_PRIVATE,
                $this->payeeType->getInputName()      => KfCashRegisterV2FormAttribute::PAYEE_TYPE_UN_CORPORATION
            ]
        )->setValue($formContent, '');


        KfCashRegisterV2FormAttribute::getInstance(
            'payeeIdentityCardValidityPeriod',
            AttributeSupport::INPUT_TYPE_STRING,
            '收款人证件有效期'
        )->setCustomAttribute(
            ['position', 2]
        )->setValidateRules(
            KfCashRegisterV2FormValidate::stringValidate(0, 36, false)->setExcludeEq(
                [
                    [
                        $this->settlementType->getInputName() => KfCashRegisterV2FormAttribute::SETTLEMENT_TYPE_PRIVATE,
                        $this->payeeType->getInputName()      => KfCashRegisterV2FormAttribute::PAYEE_TYPE_UN_CORPORATION
                    ]
                ]
            )
        )->setAllRelations(
            [
                $this->settlementType->getInputName() => KfCashRegisterV2FormAttribute::SETTLEMENT_TYPE_PRIVATE,
                $this->payeeType->getInputName()      => KfCashRegisterV2FormAttribute::PAYEE_TYPE_UN_CORPORATION
            ]
        )->setValue($formContent, '');

        KfCashRegisterV2FormAttribute::getInstance(
            'payeeMobile',
            AttributeSupport::INPUT_TYPE_MOBILE,
            '收款人电话'
        )->setCustomAttribute(
            ['position', 2]
        )->setValidateRules(
            KfCashRegisterV2FormValidate::mobileValidate()->setExcludeEq(
                [
                    [
                        $this->settlementType->getInputName() => KfCashRegisterV2FormAttribute::SETTLEMENT_TYPE_PRIVATE,
                        $this->payeeType->getInputName()      => KfCashRegisterV2FormAttribute::PAYEE_TYPE_UN_CORPORATION
                    ]
                ]
            )
        )->setPlaceholder(
            '请填写收款人电话'
        )->setAllRelations(
            [
                $this->settlementType->getInputName() => KfCashRegisterV2FormAttribute::SETTLEMENT_TYPE_PRIVATE,
                $this->payeeType->getInputName()      => KfCashRegisterV2FormAttribute::PAYEE_TYPE_UN_CORPORATION
            ]
        )->setValue($formContent, '');

        KfCashRegisterV2FormAttribute::getInstance(
            "legalPersonBankCardFrontImg",
            AttributeSupport::INPUT_TYPE_IMG_GROUP,
            "银行卡（卡号面）",
            true
        )->registerHandleSaveValueFunc(
            KfCashRegisterV2FormAttribute::getImgGroupSaveFunc()
        )->setCustomAttribute(
            ["download", true],
            ["check", true],
            ['position', 3]
        )->setValidateRules(
            KfCashRegisterV2FormValidate::imgGroupValidate()->setExcludeEq(
                [
                    [
                        $this->businessType->getInputName()   => KfCashRegisterV2FormAttribute::BUSINESS_TYPE_SINGLE,
                        $this->settlementType->getInputName() => KfCashRegisterV2FormAttribute::SETTLEMENT_TYPE_PRIVATE,
                    ],
                    [
                        $this->businessType->getInputName()   => KfCashRegisterV2FormAttribute::BUSINESS_TYPE_BUSINESS,
                        $this->settlementType->getInputName() => KfCashRegisterV2FormAttribute::SETTLEMENT_TYPE_PRIVATE,
                    ]
                ]
            )
        )->setAllRelations(
            [$this->settlementType->getInputName() => KfCashRegisterV2FormAttribute::SETTLEMENT_TYPE_PRIVATE]
        )->setExampleImages(
            ["https://file.51kuafu.com/89/b5/a09ed9e9b91ff5fa1ecee2906d6ed74b3c795bdaa6084e416aae72075ef3.png"]
        )->setValue($formContent, "");

        KfCashRegisterV2FormAttribute::getInstance(
            "legalPersonBankCardNumber",
            AttributeSupport::INPUT_TYPE_STRING,
            "账号"
        )->setCustomAttribute(
            ['position', 3]
        )->setValidateRules(
            KfCashRegisterV2FormValidate::stringValidate(12, 20)->setExcludeEq(
                [
                    $this->businessType->getInputName()   => KfCashRegisterV2FormAttribute::BUSINESS_TYPE_SINGLE,
                    $this->settlementType->getInputName() => KfCashRegisterV2FormAttribute::SETTLEMENT_TYPE_PRIVATE,
                ]
            )->setExcludeEq(
                [
                    [
                        $this->businessType->getInputName()   => KfCashRegisterV2FormAttribute::BUSINESS_TYPE_SINGLE,
                        $this->settlementType->getInputName() => KfCashRegisterV2FormAttribute::SETTLEMENT_TYPE_PRIVATE,
                    ],
                    [
                        $this->businessType->getInputName()   => KfCashRegisterV2FormAttribute::BUSINESS_TYPE_BUSINESS,
                        $this->settlementType->getInputName() => KfCashRegisterV2FormAttribute::SETTLEMENT_TYPE_PRIVATE,
                    ]
                ]
            )
        )->setAllRelations(
            [$this->settlementType->getInputName() => KfCashRegisterV2FormAttribute::SETTLEMENT_TYPE_PRIVATE]
        )->setPlaceholder(
            "请填写开户银行卡号"
        )->setValue($formContent, "");

        KfCashRegisterV2FormAttribute::getInstance(
            "legalPersonBankCardBank",
            AttributeSupport::INPUT_TYPE_SELECT,
            "开户银行"
        )->setCustomAttribute(
            ['position', 3]
        )->setValidateRules(
            KfCashRegisterV2FormValidate::stringValidate(1, 12)->setExcludeEq(
                [
                    [
                        $this->businessType->getInputName()   => KfCashRegisterV2FormAttribute::BUSINESS_TYPE_SINGLE,
                        $this->settlementType->getInputName() => KfCashRegisterV2FormAttribute::SETTLEMENT_TYPE_PRIVATE,
                    ],
                    [
                        $this->businessType->getInputName()   => KfCashRegisterV2FormAttribute::BUSINESS_TYPE_BUSINESS,
                        $this->settlementType->getInputName() => KfCashRegisterV2FormAttribute::SETTLEMENT_TYPE_PRIVATE,
                    ]
                ]
            )
        )->setAllRelations(
            [$this->settlementType->getInputName() => KfCashRegisterV2FormAttribute::SETTLEMENT_TYPE_PRIVATE]
        )->setOptions(
            KfCashRegisterV2FormAttribute::FY_BANK_TYPE
        )->setPlaceholder(
            "请填写开户银行"
        )->setValue($formContent, "");

        KfCashRegisterV2FormAttribute::getInstance(
            "legalPersonBankCardBankArea",
            AttributeSupport::INPUT_TYPE_FY_ADDRESS,
            "银行所在省市区"
        )->setCustomAttribute(
            ['position', 3]
        )->setValidateRules(
            KfCashRegisterV2FormValidate::fyAddressValidate()->setExcludeEq(
                [
                    [
                        $this->businessType->getInputName()   => KfCashRegisterV2FormAttribute::BUSINESS_TYPE_SINGLE,
                        $this->settlementType->getInputName() => KfCashRegisterV2FormAttribute::SETTLEMENT_TYPE_PRIVATE,
                    ],
                    [
                        $this->businessType->getInputName()   => KfCashRegisterV2FormAttribute::BUSINESS_TYPE_BUSINESS,
                        $this->settlementType->getInputName() => KfCashRegisterV2FormAttribute::SETTLEMENT_TYPE_PRIVATE,
                    ]
                ]
            )
        )->setAllRelations(
            [$this->settlementType->getInputName() => KfCashRegisterV2FormAttribute::SETTLEMENT_TYPE_PRIVATE]
        )->setPlaceholder(
            "请填写开户行所在省市区"
        )->setValue($formContent, []);

        KfCashRegisterV2FormAttribute::getInstance(
            "legalPersonBankCardBranchBank",
            AttributeSupport::INPUT_TYPE_SELECT,
            "开户支行"
        )->setCustomAttribute(
            ['position', 3]
        )->setValidateRules(
            KfCashRegisterV2FormValidate::stringValidate(1, 36)->setExcludeEq(
                [
                    [
                        $this->businessType->getInputName()   => KfCashRegisterV2FormAttribute::BUSINESS_TYPE_SINGLE,
                        $this->settlementType->getInputName() => KfCashRegisterV2FormAttribute::SETTLEMENT_TYPE_PRIVATE,
                    ],
                    [
                        $this->businessType->getInputName()   => KfCashRegisterV2FormAttribute::BUSINESS_TYPE_BUSINESS,
                        $this->settlementType->getInputName() => KfCashRegisterV2FormAttribute::SETTLEMENT_TYPE_PRIVATE,
                    ]
                ]
            )
        )->setAllRelations(
            [$this->settlementType->getInputName() => KfCashRegisterV2FormAttribute::SETTLEMENT_TYPE_PRIVATE]
        )->setOptions(
            []
        )->setPlaceholder(
            "请填写开户支行"
        )->setValue($formContent, "");


        KfCashRegisterV2FormAttribute::getInstance(
            "legalPersonBankCardReserveMobile",
            AttributeSupport::INPUT_TYPE_MOBILE,
            "预留手机号"
        )->setCustomAttribute(
            ['position', 3]
        )->setValidateRules(
            KfCashRegisterV2FormValidate::mobileValidate()->setExcludeEq(
                [
                    [
                        $this->businessType->getInputName()   => KfCashRegisterV2FormAttribute::BUSINESS_TYPE_SINGLE,
                        $this->settlementType->getInputName() => KfCashRegisterV2FormAttribute::SETTLEMENT_TYPE_PRIVATE,
                    ],
                    [
                        $this->businessType->getInputName()   => KfCashRegisterV2FormAttribute::BUSINESS_TYPE_BUSINESS,
                        $this->settlementType->getInputName() => KfCashRegisterV2FormAttribute::SETTLEMENT_TYPE_PRIVATE,
                    ]
                ]
            )
        )->setAllRelations(
            [$this->settlementType->getInputName() => KfCashRegisterV2FormAttribute::SETTLEMENT_TYPE_PRIVATE]
        )->setPlaceholder(
            "请填写预留手机号"
        )->setValue($formContent, "");

    }


    /**
     * @param Collection $formContent
     * @return $this
     */
    public function renderForm(Collection $formContent): KfCashRegisterV2Form
    {
        $this->businessInfo($formContent);
        $this->licenseInformation($formContent);
        $this->legalPersonInfo($formContent);
        $this->collectionInformationForm($formContent);
        return $this;
    }


    /**
     * @return array[]
     * workOrderNo
     */
    public function getFormContent(): array
    {

        return [
            [
                "title"      => "商户信息",
                "attributes" => collect([
                    $this->businessType,//商户类型
                    $this->settlementType,//结算方式
                    $this->authorizationLetterImg,
                ])->map(function (KfCashRegisterV2FormAttribute $attribute) {
                    return $attribute->build();
                })->values()->toArray(),
            ],
            [
                'title'      => '执照信息',
                'attributes' => collect(
                    [
                        $this->businessLicenseImg,
                        $this->businessCompanyArea,
                        $this->enterpriseName,
                        $this->businessLicenseNumber,
                        $this->businessLicenseRegistrationDate,
                        $this->businessLicenseValidityPeriodType,
                        $this->businessLicenseEndDate,
                        $this->businessPremises,
                        $this->businessUserName,
                    ]
                )->map(
                    function (KfCashRegisterV2FormAttribute $attribute) {
                        return $attribute->build();
                    }
                )->values()->toArray(),
            ],
            [
                "title"      => "法人信息",
                "attributes" => collect([
                    $this->legalPersonIdentityCardFront,
                    $this->legalPersonIdentityCardBack,
                    $this->legalPersonUsername,
                    $this->legalPersonIdentityCardNumber,
                    $this->legalPersonIdentityCardValidityPeriod,
                    $this->legalPersonMobile,
                ])->map(function (KfCashRegisterV2FormAttribute $attribute) {
                    return $attribute->build();
                })->values()->toArray(),
            ],
            [
                "title"      => "收款信息",
                "attributes" => collect([
                    $this->companyBankCardImg,
                    $this->companyBankCardNumber,
                    $this->companyBankCardBank,
                    $this->companyBankCardBankArea,
                    $this->companyBankCardBranchBank,
                    $this->companyBankCardReserveMobile,

                    $this->payeeType,
                    $this->merchantRelationshipImg,
                    $this->payeeIdentityCardFront,
                    $this->payeeIdentityCardBack,
                    $this->payeeUsername,
                    $this->payeeIdentityCardNumber,
                    $this->payeeIdentityCardValidityPeriod,
                    $this->payeeMobile,

                    $this->legalPersonBankCardFrontImg,
                    $this->legalPersonBankCardNumber,
                    $this->legalPersonBankCardBank,
                    $this->legalPersonBankCardBankArea,
                    $this->legalPersonBankCardBranchBank,
                    $this->legalPersonBankCardReserveMobile,
                ])->map(function (KfCashRegisterV2FormAttribute $attribute) {
                    return $attribute->build();
                })->values()->toArray(),
            ],
        ];
    }


//    /**
//     * @param string $field
//     * @param $value
//     * @param array $extraParams
//     * @return mixed
//     */
//    public function validate(string $field, $value, array $extraParams = [])
//    {
//        // TODO: Implement save() method.
//        CustomerValidator::extend(
//            'exclude_eq',
//            function ($attribute, $value, $parameters, Validator $validator) {
//                $validator->requireParameterCount(2, $parameters, 'eq');
//                $eqFieldName   = $parameters[0];
//                $eqFieldValue  = $parameters[1];
//                $nowFieldValue = $validator->getData()["$eqFieldName"];
//
//                return $eqFieldValue == $nowFieldValue;
//            }, "当前状态暂不支持修改 【:attribute】 字段");
//
//        return parent::validate($field, $value, $extraParams);
//    }

    /**
     * @param $name
     * @return AttributeSupport
     */
    public function __get($name)
    {
        // TODO: Change the autogenerated stub
        return $this->getAttributeMap()->{$name};
    }

    /**
     * @return AttributeMapSupport
     */
    public function getAttributeMap(): AttributeMapSupport
    {
        // TODO: Implement getAttributeValidateClassName() method.
        return KfCashRegisterV2FormAttribute::$attributesMap;
    }
}
